package com.qf.efserver.sport.controller;

import com.qf.common.core.common.R;
import com.qf.efserver.sport.param.SportDayParam;
import com.qf.efserver.sport.param.SportDistanceParam;
import com.qf.efserver.sport.param.SportDurationParam;
import com.qf.efserver.sport.param.TargetStepsParam;
import com.qf.efserver.sport.service.SportDayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

@RestController
@RequiredArgsConstructor
@RequestMapping("/sportDay")
@Api(tags = "每日运动")
public class SportDayController {
    public final SportDayService sportDayService;
    @GetMapping("/select")
    @ApiOperation(value = "查询第几周每天运动数据，当前周：0，上周：1")
    public R<SportDayParam> select(@RequestParam Integer weekId){
        SportDayParam sportDayParam = sportDayService.selectWeek(weekId);
        return R.ok(sportDayParam);
    }
    @GetMapping("/targetSteps")
    @ApiOperation(value = "查询某日运动步数目标")
    @ApiImplicitParam(name = "localDate",value = "日期")
    public R<Integer> selectTarget(@RequestParam LocalDate localDate){
        Integer target = sportDayService.selectTargetSteps(localDate);
        return R.ok(target);
    }
    @PostMapping("/addtargetSteps")
    @ApiOperation(value = "添加今日运动步数目标或修改今日运动步数目标")
    @ApiImplicitParam(name = "target",value = "运动目标步数")
    public R addTargetSteps(@RequestParam Integer target){
        sportDayService.addTargetSteps(target);
        return R.ok();
    }
    @PostMapping("/addtargetDistance")
    @ApiOperation(value = "添加今日运动距离目标或修改今日运动距离目标")
    @ApiImplicitParam(name = "targetDistance",value = "运动目标距离")
    public R addTargetDistance(@RequestParam Double targetDistance){
        sportDayService.addTargetDistance(targetDistance);
        return R.ok();
    }

    @GetMapping("/daystepsTarget")
    @ApiOperation(value = "首页展示关于运动的接口")
    public R<TargetStepsParam> selectDayStepsTarget(){
        TargetStepsParam targetStepsParam = sportDayService.selectTargetParam();
        return R.ok(targetStepsParam);
    }

    @GetMapping("/selectDistance")
    @ApiOperation(value = "查询运动距离，日")
    public R<SportDistanceParam> selectDistanceDay(@RequestParam LocalDate localDate){
        SportDistanceParam sportDistanceParam = sportDayService.selectDistanceDay(localDate);
        return R.ok(sportDistanceParam);
    }
    @GetMapping("/selectWeekDistance")
    @ApiOperation(value = "查询运动距离，周")
    public R<SportDistanceParam> selectWeekDistance(@RequestParam Integer weekId){
        SportDistanceParam sportDistanceParam = sportDayService.selectDistanceWeek(weekId);
        return R.ok(sportDistanceParam);
    }
    @GetMapping("/selectMonthDistance")
    @ApiOperation(value = "查询运动距离，月")
    public R<SportDistanceParam> selectMonthDistance(@RequestParam Integer monthId){
        SportDistanceParam sportDistanceParam = sportDayService.selectDistanceMonth(monthId);
        return R.ok(sportDistanceParam);
    }
    @GetMapping("/selectDayDuration")
    @ApiOperation(value = "查询运动时长，日")
    public R<SportDurationParam> selectDayDuration(@RequestParam LocalDate localDate){
        SportDurationParam sportDurationParam = sportDayService.selectDurationDay(localDate);
        return R.ok(sportDurationParam);
    }
    @GetMapping("/selectWeekDuration")
    @ApiOperation(value = "查询运动时长，周")
    public R<SportDurationParam> selectWeekDuration(@RequestParam Integer weekId){
        SportDurationParam sportDurationParam = sportDayService.selectDurationWeek(weekId);
        return R.ok(sportDurationParam);
    }
    @GetMapping("/selectMonthDuration")
    @ApiOperation(value = "查询运动时长，月")
    public R<SportDurationParam> selectMonthDuration(@RequestParam Integer monthId){
        SportDurationParam sportDurationParam = sportDayService.selectDurationMonth(monthId);
        return R.ok(sportDurationParam);
    }



}
